from selenium import webdriver
from .login import login_test
from time import sleep
from ..lib.screenshot_function import screenshot
from selenium.webdriver.chrome.options import Options


def open_browser(browser_name, url):
    driver = None
    chrome_options = Options()
    chrome_options.add_argument("--headless")
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--disable-dev-shm-usage')
    chrome_options.add_argument('--window-size=1920,1080')
    if browser_name == "chrome":
        driver = webdriver.Chrome(chrome_options=chrome_options)
    if browser_name == "ff":
        driver = webdriver.Firefox()
    if browser_name == "ie":
        driver = webdriver.Ie()
    driver.maximize_window()
    driver.implicitly_wait(10)
    driver.get(url)
    return driver


class TestKeys(object):

    def __init__(self, browser_name, url, username, password, new_password):
        self.driver = open_browser(browser_name, url)
        self.username = username
        self.password = password
        self.new_password = new_password

    def webui1(self, list_dicts):
        # 登录
        driver = login_test(self.username, self.driver, self.new_password)
        # 任务管理
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[3]').click()
        sleep(1)
        # 任务一览
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[3]/ul').click()
        sleep(1)
        returns_list = []
        for dicts in list_dicts:
            if dicts["task_name"] and dicts["scan_type"] and dicts["task_state"] and dicts["run_mode"] and dicts["date_created"] is not None:
                # 任务名称
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(
                    dicts["task_name"])
                sleep(1)
                if dicts["scan_type"] == "离线扫描":
                    # 扫描类型
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/span/span').click()
                    # 扫描类型-离线扫描
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[1]').click()
                elif dicts["scan_type"] == "在线扫描":
                    # 扫描类型
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/span/span').click()
                    # 扫描类型-在线扫描
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[2]').click()

                if dicts["task_state"] == "未执行":
                    print(dicts["task_state"], "未执行")
                    # 任务状态
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                    # 任务状态-未执行
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[1]').click()
                elif dicts["task_state"] == "执行中":
                    print(dicts["task_state"], "执行中")
                    # 任务状态
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                    # 任务状态-执行中
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[2]').click()
                elif dicts["task_state"] == "完成":
                    print(dicts["task_state"], "完成")
                    # 任务状态
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                    # 任务状态-完成
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[3]').click()
                elif dicts["task_state"] == "异常中断":
                    print(dicts["task_state"], "异常中断")
                    # 任务状态
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                    # 任务状态-异常中断
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[4]').click()
                elif dicts["task_state"] == "停止":
                    print(dicts["task_state"], "停止")
                    # 任务状态
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                    # 任务状态-停止
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[5]').click()
                if dicts["run_mode"] == "手动执行":
                    # 执行方式
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                    # 执行方式-手动执行
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[1]').click()
                elif dicts["run_mode"] == "定时执行":
                    # 执行方式
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                    # 执行方式-定时执行
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[2]').click()
                elif dicts["run_mode"] == "立即执行":
                    # 执行方式
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                    # 执行方式-立即执行
                    driver.find_element_by_xpath('/html/body/div[8]/div[1]/div[1]/ul/li[3]').click()
                # 创建日期
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[2]/div/div/div/input[1]').send_keys(
                    dicts["date_created"][0])
                sleep(2)
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[2]/div/div/div/input[2]').send_keys(
                    dicts["date_created"][1])
                # 点一下
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').click()
                # 查询
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                sleep(2)
                error_text = driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                print(error_text)
                if error_text == "":
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                    print(error_text)
                returns_list.append(error_text)
                # driver.refresh()
                # 重置
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                sleep(2)
                continue
            if dicts["task_name"] is not None:
                # 任务名称
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(dicts["task_name"])
                sleep(1)
                # 查询
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                sleep(2)
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                print(error_text)
                if error_text == "":
                    error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                    print(error_text)
                returns_list.append(error_text)
                # driver.refresh()
                # 重置
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                sleep(2)
                continue
            if dicts["scan_type"] is not None:
                if dicts["scan_type"] == "离线扫描":
                    # 扫描类型
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/span/span').click()
                    # 扫描类型-离线扫描
                    driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[1]').click()
                    # 查询
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                    sleep(2)
                    error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                    print(error_text)
                    if error_text == "":
                        error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                        print(error_text)
                    returns_list.append(error_text)
                    # driver.refresh()
                    # 重置
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                    sleep(2)
                    continue
                elif dicts["scan_type"] == "在线扫描":
                    # 扫描类型
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/span/span').click()
                    # 扫描类型-在线扫描
                    driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[2]').click()
                    # 查询
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                    sleep(2)
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                    print(error_text)
                    if error_text == "":
                        error_text = driver.find_element_by_xpath(
                            '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                        print(error_text)
                    returns_list.append(error_text)
                    # driver.refresh()
                    # 重置
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                    sleep(2)
                    continue
            if dicts["task_state"] is not None:
                if dicts["task_state"] == "未执行":
                    print(dicts["task_state"], "未执行")
                    # 任务状态
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                    # 任务状态-未执行
                    driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[1]').click()
                    # 查询
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                    sleep(2)
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                    print(error_text)
                    if error_text == "":
                        error_text = driver.find_element_by_xpath(
                            '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                        print(error_text)
                    returns_list.append(error_text)
                    # driver.refresh()
                    # 重置
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                    sleep(2)
                    continue
                elif dicts["task_state"] == "执行中":
                    print(dicts["task_state"], "执行中")
                    # 任务状态
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                    # 任务状态-执行中
                    driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[2]').click()
                    # 查询
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                    sleep(2)
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                    print(error_text)
                    if error_text == "":
                        error_text = driver.find_element_by_xpath(
                            '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                        print(error_text)
                    returns_list.append(error_text)
                    # driver.refresh()
                    # 重置
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                    sleep(2)
                    continue
                elif dicts["task_state"] == "完成":
                    print(dicts["task_state"], "完成")
                    # 任务状态
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                    # 任务状态-完成
                    driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[3]').click()
                    # 查询
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                    sleep(2)
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                    print(error_text)
                    if error_text == "":
                        error_text = driver.find_element_by_xpath(
                            '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                        print(error_text)
                    returns_list.append(error_text)
                    # driver.refresh()
                    # 重置
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                    sleep(2)
                    continue
                elif dicts["task_state"] == "异常中断":
                    print(dicts["task_state"], "异常中断")
                    # 任务状态
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                    # 任务状态-异常中断
                    driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[4]').click()
                    # 查询
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                    sleep(2)
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                    print(error_text)
                    if error_text == "":
                        error_text = driver.find_element_by_xpath(
                            '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                        print(error_text)
                    returns_list.append(error_text)
                    # driver.refresh()
                    # 重置
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                    sleep(2)
                    continue
                elif dicts["task_state"] == "停止":
                    print(dicts["task_state"], "停止")
                    # 任务状态
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                    # 任务状态-停止
                    driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[5]').click()
                    # 查询
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                    sleep(2)
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                    print(error_text)
                    if error_text == "":
                        error_text = driver.find_element_by_xpath(
                            '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                        print(error_text)
                    returns_list.append(error_text)
                    # driver.refresh()
                    # 重置
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                    sleep(2)
                    continue
            # # 扫描对象
            # driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div[1]/span/span').click()
            # # 扫描对象-操作系统
            # driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[2]').click()
            # # 查询
            # driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
            # sleep(1)
            # # 重置
            # driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
            if dicts["run_mode"] is not None:
                if dicts["run_mode"] == "手动执行":
                    # 执行方式
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                    # 执行方式-手动执行
                    driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[1]').click()
                    # 查询
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                    sleep(2)
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                    print(error_text)
                    if error_text == "":
                        error_text = driver.find_element_by_xpath(
                            '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                        print(error_text)
                    returns_list.append(error_text)
                    # driver.refresh()
                    # 重置
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                    sleep(2)
                    continue
                elif dicts["run_mode"] == "定时执行":
                    # 执行方式
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                    # 执行方式-定时执行
                    driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[2]').click()
                    # 查询
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                    sleep(2)
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                    print(error_text)
                    if error_text == "":
                        error_text = driver.find_element_by_xpath(
                            '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                        print(error_text)
                    returns_list.append(error_text)
                    # driver.refresh()
                    # 重置
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                    sleep(2)
                    continue
                elif dicts["run_mode"] == "立即执行":
                    # 执行方式
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                    # 执行方式-立即执行
                    driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[3]').click()
                    # 查询
                    driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                    sleep(2)
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                    print(error_text)
                    if error_text == "":
                        error_text = driver.find_element_by_xpath(
                            '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                        print(error_text)
                    returns_list.append(error_text)
                    # driver.refresh()
                    # 重置
                    driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                    sleep(2)
                    continue
            if dicts["date_created"] is not None:
                # 创建日期
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[2]/div/div/div/input[1]').send_keys(dicts["date_created"][0])
                sleep(2)
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[2]/div/div/div/input[2]').send_keys(dicts["date_created"][1])
                # 点一下
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').click()
                # 查询
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
                sleep(2)
                error_text = driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[2]/footer/div/div/slot/span').text
                print(error_text)
                if error_text == "":
                    error_text = driver.find_element_by_xpath(
                        '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
                    print(error_text)
                returns_list.append(error_text)
                # driver.refresh()
                # 重置
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
                sleep(2)
                continue
        print(returns_list)
        return returns_list

    def webui2(self, list_dicts):
        # 登录
        driver = login_test(self.username, self.driver, self.new_password)
        # 任务管理
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[3]').click()
        sleep(1)
        # 任务一览
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[3]/ul').click()
        sleep(1)
        # 在线任务
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/header/div[2]/button[1]').click()
        sleep(1)
        returns_list = []
        for dicts in list_dicts:
            if dicts["task_name"] is not None:
                # 任务名称
                driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/form/div[1]/div/div/div/div[1]/input').send_keys(dicts["task_name"])
            # 任务描述
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/form/div[2]/div/div/div/div/textarea').send_keys("在线任务描述测试1")
            # # 描述方式
            # driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/form/div[3]/div/div/label[1]/span[2]').click()
            # sleep(1)
            # 下一步
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div/button').click()
            sleep(2)
            if dicts["task_name"] == dicts["task_name_2"]:
                alert_text = driver.find_element_by_xpath("/html/body/div[2]/p").text
                print(alert_text)
                returns_list.append(alert_text)
                driver.refresh()
                sleep(2)
                continue
            if dicts["task_name"] is None:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/form/div[1]/div/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                sleep(2)
                continue
            if len(dicts["task_name"]) > 32:
                error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/form/div[1]/div/div/div/div[2]').text
                print(error_text)
                returns_list.append(error_text)
                driver.refresh()
                sleep(2)
                continue
            # 资产名称
            # driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/form/div/div/div/div/div/div[1]/span/span').click()
            # driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[1]/span').click()
            # sleep(2)
            # 下一步
            sleep(2)
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[2]/button[2]').click()
            sleep(2)
            # 批量设置
            # driver.find_element_by_xpath('//*[@id="pane-mysql信息设定"]/div[1]/button[1]').click()
            # 用户名称
            driver.find_element_by_xpath('//*[@id="pane-mysql信息设定"]/div/form/div/div[3]/table/tbody/tr/td[3]/div/div/div/div[1]/input').send_keys("root")
            # 密码
            driver.find_element_by_xpath('//*[@id="pane-mysql信息设定"]/div/form/div/div[3]/table/tbody/tr/td[4]/div/div/div/div[1]/input').send_keys("idss@1234")
            # 端口
            driver.find_element_by_xpath('//*[@id="pane-mysql信息设定"]/div/form/div/div[3]/table/tbody/tr/td[5]/div/div/div/div/input').send_keys('22')
            sleep(1)
            # # 保存
            # driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[3]/div/div[2]/div/div/button[2]').click()
            # sleep(1)
            # 下一步
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[2]/button[2]').click()
            sleep(1)
            # 选择模板-模板名称
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/main/form/div/div/div/div/div/div[1]/input').click()
            sleep(1)
            # linux默认模板
            driver.find_element_by_xpath('/html/body/div[2]/div[1]/div[1]/ul/li[6]').click()
            # 保存
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[3]/button[2]').click()
            sleep(5)
            # 任务名称
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(dicts["task_name"])
            sleep(1)
            # 查询
            driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
            sleep(2)
            returns_list.append("新增成功")
            print("新增成功")
            driver.refresh()
            sleep(2)
            # 在线任务
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[2]/header/div[2]/button[1]').click()
            sleep(1)
            continue

        print(returns_list)
        return returns_list

    def webui3(self, username):
        # 登录
        driver = login_test(username, self.driver, self.new_password)
        # 任务管理
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[3]').click()
        sleep(1)
        # 任务一览
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[3]/ul').click()
        sleep(1)
        # 离线任务
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/header/div[2]/button[2]').click()
        sleep(1)
        # 任务基础信息-任务名称
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/div[1]/form/div[1]/div/div[1]/input').send_keys("离线任务测试1")
        # 任务描述
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/div[1]/form/div[2]/div/div/textarea').send_keys("离线任务描述测试1")
        sleep(2)
        # 检查结果上传-导入xml文件
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/div[2]/div[2]/div[2]/div/div[1]/input').send_keys("C:\\Users\\wangliliang\\Desktop\\基线\基线\\10.30.10.5_system_CentOS7_20200909_check.xml")
        sleep(2)
        # 检查模板选择
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/div[3]/form/div/div/div/div/span/span').click()
        sleep(1)
        # linux默认模板
        driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[6]').click()
        # 保存
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[2]/button[1]').click()
        sleep(4)

        return "执行成功"

    def webui4(self, username):
        # 登录
        driver = login_test(username, self.driver, self.new_password)
        # 任务管理
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[3]').click()
        sleep(1)
        # 任务一览
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[3]/ul').click()
        sleep(1)
        # 离线任务
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/header/div[2]/button[2]').click()
        sleep(1)
        # 检查脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[1]/label[2]').click()
        # 离线脚本下载-中间件-Linux-tomcat
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/button').click()
        # 离线脚本下载-中间件-Linux-apache
        # 组件类型-apache
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[3]/div/div/div/div[1]/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[2]').click()
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/button').click()
        sleep(1)
        # 离线脚本下载-中间件-Linux-jboss
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[3]/div/div/div/div[1]/span/span').click()
        driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[3]').click()
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/button').click()
        sleep(1)
        # 离线脚本下载-中间件-Linux-weblogic
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[3]/div/div/div/div[1]/span/span').click()
        driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[4]').click()
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/button').click()
        sleep(1)
        # 系统类型-windows
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[2]/div/div/div[1]/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[2]').click()
        sleep(1)
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/button').click()
        sleep(1)
        # 组件类型-apache
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[3]/div/div/div/div/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[2]').click()
        sleep(1)
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/button').click()
        # 组件类型-jboss
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[3]/div/div/div/div/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[3]').click()
        sleep(1)
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/button').click()
        sleep(1)
        # 组件类型-
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[3]/div/div/div/div/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[4]').click()
        sleep(1)
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/button').click()
        sleep(1)
        # 脚本检查类型-操作系统
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[1]/div/div/div[1]/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[2]').click()
        sleep(1)
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[3]/div/button').click()
        sleep(1)
        # 系统类型-windows
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[2]/div/div/div/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[2]').click()
        sleep(1)
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[3]/div/button').click()
        sleep(1)
        # 脚本检查类型-数据库
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[1]/div/div/div/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[3]').click()
        sleep(1)
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/button').click()
        sleep(1)
        # 组件类型-mysql
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[3]/div/div/div/div[1]/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[2]').click()
        # 脚本参数-用户名
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[1]/div/div/input').send_keys("root")
        # 脚本参数-密码
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[2]/div/div/input').send_keys("idss@1234")
        # 脚本参数-端口
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[3]/div/div/input').send_keys("22")
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[5]/div/button').click()
        # 系统类型-windows
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[2]/div/div/div/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[2]').click()
        sleep(1)
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/button').click()
        sleep(1)
        # 脚本检查类型-网络设备
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[1]/div/div/div/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[4]').click()
        sleep(1)
        # 脚本参数-IP
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[1]/div/div/input').send_keys("192.168.50.211")
        # 脚本参数-用户名
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[2]/div/div/input').send_keys("root")
        # 脚本参数-密码
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[3]/div/div/input').send_keys("idss@1234")
        # 脚本参数-特权密码
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[4]/div/div/input').send_keys("idss@1234")
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[5]/div/button')
        sleep(1)
        # 脚本检查类型-安全设备
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[1]/div/div/div/span/span').click()
        sleep(1)
        driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[5]').click()
        # 脚本参数-IP
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[4]/div/div/input').send_keys("192.168.50.211")
        # 脚本参数-用户名
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[2]/div/div/input').send_keys("root")
        # 脚本参数-密码
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[3]/div/div/input').send_keys("idss@1234")
        # 脚本参数-特权密码
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[4]/div/div/div[4]/div/div/input').send_keys("idss@1234")
        # 脚本下载
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[1]/form/div[5]/div/button').click()
        sleep(1)
        # 返回
        driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div/main/div[2]/div[2]/button').click()
        sleep(5)
        return "执行成功"

    def webui5(self, list_dicts):
        # 登录
        driver = login_test(self.username, self.driver, self.new_password)
        # 任务管理
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[3]').click()
        sleep(1)
        # 任务一览
        driver.find_element_by_xpath('//*[@id="app"]/section/section/aside/div/ul/div/li[3]/ul').click()
        sleep(1)
        returns_list = []
        for dicts in list_dicts:
            # 任务名称
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(
                dicts["task_name"])
            sleep(1)
            if dicts["scan_type"] == "离线扫描":
                # 扫描类型
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/span/span').click()
                # 扫描类型-离线扫描
                driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[1]').click()
            elif dicts["scan_type"] == "在线扫描":
                # 扫描类型
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/span/span').click()
                # 扫描类型-在线扫描
                driver.find_element_by_xpath('/html/body/div[5]/div[1]/div[1]/ul/li[2]').click()

            if dicts["task_state"] == "未执行":
                print(dicts["task_state"], "未执行")
                # 任务状态
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                # 任务状态-未执行
                driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[1]').click()
            elif dicts["task_state"] == "执行中":
                print(dicts["task_state"], "执行中")
                # 任务状态
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                # 任务状态-执行中
                driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[2]').click()
            elif dicts["task_state"] == "完成":
                print(dicts["task_state"], "完成")
                # 任务状态
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                sleep(1)
                # 任务状态-完成
                driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[3]').click()
            elif dicts["task_state"] == "异常中断":
                print(dicts["task_state"], "异常中断")
                # 任务状态
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                # 任务状态-异常中断
                driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[4]').click()
            elif dicts["task_state"] == "停止":
                print(dicts["task_state"], "停止")
                # 任务状态
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                # 任务状态-停止
                driver.find_element_by_xpath('/html/body/div[6]/div[1]/div[1]/ul/li[5]').click()
            if dicts["run_mode"] == "手动执行":
                # 执行方式
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                # 执行方式-手动执行
                driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[1]').click()
            elif dicts["run_mode"] == "定时执行":
                # 执行方式
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                # 执行方式-定时执行
                driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[2]').click()
            elif dicts["run_mode"] == "立即执行":
                # 执行方式
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                # 执行方式-立即执行
                driver.find_element_by_xpath('/html/body/div[7]/div[1]/div[1]/ul/li[3]').click()
            # 创建日期
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[2]/div/div/div/input[1]').send_keys(
                dicts["date_created"][0])
            sleep(2)
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[2]/div/div/div/input[2]').send_keys(
                dicts["date_created"][1])
            # 点一下
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').click()
            # 查询
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
            sleep(2)
            # 删除
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/table/tbody/tr/td[10]/div/button[3]').click()
            sleep(1)
            # 确定
            driver.find_element_by_xpath(
                '/html/body/div[10]/div/div[3]/button[2]').click()
            sleep(1)
            # 重置
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
            sleep(1)
            # 任务名称
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').send_keys(
                dicts["task_name"])
            sleep(1)
            if dicts["scan_type"] == "离线扫描":
                # 扫描类型
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/span/span').click()
                # 扫描类型-离线扫描
                driver.find_element_by_xpath('/html/body/div[9]/div[1]/div[1]/ul/li[1]').click()
            elif dicts["scan_type"] == "在线扫描":
                # 扫描类型
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[2]/div/div/div/div/span/span').click()
                sleep(1)
                # 扫描类型-在线扫描
                driver.find_element_by_xpath('/html/body/div[9]/div[1]/div[1]/ul/li[2]').click()

            if dicts["task_state"] == "未执行":
                print(dicts["task_state"], "未执行")
                # 任务状态
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                # 任务状态-未执行
                driver.find_element_by_xpath('/html/body/div[9]/div[1]/div[1]/ul/li[1]').click()
            elif dicts["task_state"] == "执行中":
                print(dicts["task_state"], "执行中")
                # 任务状态
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                # 任务状态-执行中
                driver.find_element_by_xpath('/html/body/div[9]/div[1]/div[1]/ul/li[2]').click()
            elif dicts["task_state"] == "完成":
                print(dicts["task_state"], "完成")
                # 任务状态
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                # 任务状态-完成
                driver.find_element_by_xpath('/html/body/div[9]/div[1]/div[1]/ul/li[3]').click()
            elif dicts["task_state"] == "异常中断":
                print(dicts["task_state"], "异常中断")
                # 任务状态
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                # 任务状态-异常中断
                driver.find_element_by_xpath('/html/body/div[9]/div[1]/div[1]/ul/li[4]').click()
            elif dicts["task_state"] == "停止":
                print(dicts["task_state"], "停止")
                # 任务状态
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[3]/div/div/div/div[1]/span/span').click()
                # 任务状态-停止
                driver.find_element_by_xpath('/html/body/div[9]/div[1]/div[1]/ul/li[5]').click()
            if dicts["run_mode"] == "手动执行":
                # 执行方式
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                # 执行方式-手动执行
                driver.find_element_by_xpath('/html/body/div[9]/div[1]/div[1]/ul/li[1]').click()
            elif dicts["run_mode"] == "定时执行":
                # 执行方式
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                # 执行方式-定时执行
                driver.find_element_by_xpath('/html/body/div[9]/div[1]/div[1]/ul/li[2]').click()
            elif dicts["run_mode"] == "立即执行":
                # 执行方式
                driver.find_element_by_xpath(
                    '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[1]/div/div/div/div/input').click()
                # 执行方式-立即执行
                driver.find_element_by_xpath('/html/body/div[9]/div[1]/div[1]/ul/li[3]').click()
            # 创建日期
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[2]/div/div/div/input[1]').send_keys(
                dicts["date_created"][0])
            sleep(2)
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[2]/div[2]/div/div/div/input[2]').send_keys(
                dicts["date_created"][1])
            # 点一下
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[1]/div[1]/div/div/div/input').click()
            # 查询
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[1]').click()
            sleep(2)
            error_text = driver.find_element_by_xpath('//*[@id="app"]/section/section/main/section/div/div[2]/main/div/div[3]/div/span').text
            print(error_text)
            if error_text == "暂无数据":
                returns_list.append("删除成功")
            else:
                returns_list.append("删除失败")
            # 重置
            driver.find_element_by_xpath(
                '//*[@id="app"]/section/section/main/section/div/div[1]/main/div/main/form/div[3]/button[2]').click()
            continue
        print(returns_list)
        return returns_list

    def quit(self):
        """
        浏览器退出
        :return:
        """
        self.driver.quit()